package belf.migrate.evaluate.type;

import belf.migrate.api.type.LevelType;

public enum IndexType {
    MYSQL_DM_HASH("MYSQL", "DAMENG", "hash", "", LevelType.ERROR, "达梦数据库没有与MYSQL完全相同的哈希索引类型。"),
    MYSQL_DM_FULLTEXT("MYSQL", "DAMENG", "fulltext", "", LevelType.ERROR, "达梦数据库有自己的全文索引解决方案，在迁移时，需要考虑全文索引的语法、分词规则以及查询方式的不同。例如，达梦数据库的全文索引在分词策略上可能与 MySQL 不同，会影响到对文本内容的索引和检索效果。"),
    MYSQL_DM_SPATIAL("MYSQL", "DAMENG", "spatial", "", LevelType.ERROR, "MySQL 使用的空间索引在数据存储格式和索引构建算法上与达梦数据库的空间索引不同。在迁移时，需要重新创建空间索引，并且可能需要调整与空间数据查询相关的 SQL 语句，以符合达梦数据库的空间索引查询语法。"),
    DEFAULT("DEFAULT", "DEFAULT", "", "", LevelType.NORMAL, "");


    private String sourceCatalogName;

    private String sinkCatalogName;

    private String from;

    private String to;

    private LevelType level;

    private String desc;

    IndexType(String sourceCatalogName, String sinkCatalogName, String from, String to, LevelType level, String desc) {
        this.sourceCatalogName = sourceCatalogName;
        this.sinkCatalogName = sinkCatalogName;
        this.from = from;
        this.to = to;
        this.level = level;
        this.desc = desc;
    }

    public static IndexType getIndexType(String sourceCatalogName, String sinkCatalogName, String from) {
        for (IndexType indexType : IndexType.values()) {
            if (indexType.sourceCatalogName.equalsIgnoreCase(sourceCatalogName) && indexType.sinkCatalogName.equalsIgnoreCase(sinkCatalogName) && indexType.from.equalsIgnoreCase(from)) {
                return indexType;
            }
        }
        return null;
    }

    public String getSourceCatalogName() {
        return sourceCatalogName;
    }

    public void setSourceCatalogName(String sourceCatalogName) {
        this.sourceCatalogName = sourceCatalogName;
    }

    public String getSinkCatalogName() {
        return sinkCatalogName;
    }

    public void setSinkCatalogName(String sinkCatalogName) {
        this.sinkCatalogName = sinkCatalogName;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public LevelType getLevel() {
        return level;
    }

    public void setLevel(LevelType level) {
        this.level = level;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
